package org.webframe.service;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.security.crypto.bcrypt.BCryptPasswordEncoder;
import org.springframework.stereotype.Service;
import org.webframe.dao.SysUserDao;
import org.webframe.entity.SysUser;
import org.webframe.enums.LogicDeleteEnum;


@Service
public class SysUserService {

	@Autowired
    private SysUserDao sysUserDao;
	
	public void save(SysUser entity) {
		entity.setPassword(new BCryptPasswordEncoder().encode("123456"));
        sysUserDao.insert(entity);
    }

	public SysUser findByExample(SysUser example) {
		example.setLogicDelete(LogicDeleteEnum.N.toString());
		SysUser sysUser = sysUserDao.templateOne(example);
		return sysUser;
	}
	
}
